package com.example.makerspace.controller.meeting;

import com.example.makerspace.dto.MeetingCategoryDTO;
import com.example.makerspace.dto.MeetingDTO;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.MeetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@ResponseBody
@RequestMapping("/api/meeting")
@Api(tags = "会议模块")
public class MeetingController {

    @Resource
    private MeetingService meetingService;


    @ApiOperation(value="前台-获取会议列表接口",notes ="前台-获取会议列表接口说明")
    @PostMapping("/getMeetings")
    public Result getMeetings(@RequestBody PageRequest pageRequest) {
        return meetingService.getMeetings(pageRequest);
    }

    @ApiOperation(value="前台-点击预约接口",notes ="前台-点击预约接口说明")
    @GetMapping("/clickBooking")
    public Result clickBooking(@RequestParam("id") Integer id, HttpServletRequest request) {
        return meetingService.clickBooking(id,request);
    }

    @ApiOperation(value="前台-相关推荐接口",notes ="前台-相关推荐接口说明")
    @GetMapping("/recommend")
    public Result recommend() {
        return meetingService.recommend();
    }


    @ApiOperation(value="前台-获取会议分类",notes ="前台-获取会议分类说明")
    @GetMapping("/getMeetingCategory")
    public Result getMeetingCategory() {
        return meetingService.getMeetingCategory();
    }

    @ApiOperation(value="前台-点击预约接口",notes ="前台-点击预约接口说明")
    @GetMapping("/cancelBooking")
    public Result cancelBooking(@RequestParam("id") Integer id, HttpServletRequest request) {
        return meetingService.cancelBooking(id,request);
    }

    @ApiOperation(value="前台-获取会议列表详情接口",notes ="前台-获取会议列表接口说明")
    @GetMapping("/getDetailMeeting")
    public Result getDetailMeeting(@RequestParam("id") Integer id) {
        return meetingService.getDetailMeeting(id);
    }


    @ApiOperation(value="后台-获取所有会议分类",notes ="前台-获取所有会议分类说明")
    @PostMapping("/getMeetingAllCategory")
    public Result getMeetingAllCategory(@RequestBody PageRequest pageRequest) {
        return meetingService.getMeetingAllCategory(pageRequest);
    }

    @ApiOperation(value="后台-增加会议分类",notes ="前台-获取所有会议分类说明")
    @PostMapping("/addMeetingCategory")
    public Result addMeetingCategory(@RequestBody MeetingCategoryDTO meetingCategoryDTO) {
        return meetingService.addMeetingCategory(meetingCategoryDTO);
    }

    @ApiOperation(value="后台-修改会议分类",notes ="后台-修改会议分类说明")
    @PostMapping("/updateMeetingCategory")
    public Result updateMeetingCategory(@RequestBody MeetingCategoryDTO meetingCategoryDTO) {
        return meetingService.updateMeetingCategory(meetingCategoryDTO);
    }

    @ApiOperation(value="后台-删除会议分类",notes ="后台-删除会议分类说明")
    @GetMapping("/deleteMeetingCategory")
    public Result deleteMeetingCategory(@RequestParam("id")Integer id) {
        return meetingService.deleteMeetingCategory(id);
    }

    @ApiOperation(value="后台-增加会议接口",notes ="后台-增加会议接口说明")
    @PostMapping("/addMeeting")
    public Result addMeetings(@ModelAttribute MeetingDTO meetingDTO) {
        return meetingService.addMeetings(meetingDTO);
    }

    @ApiOperation(value="后台-修改会议接口",notes ="后台-修改会议接口说明")
    @PostMapping("/updateMeetings")
    public Result updateMeetings(@ModelAttribute MeetingDTO meetingDTO) {
        return meetingService.updateMeetings(meetingDTO);
    }

    @ApiOperation(value="后台-删除会议列表",notes ="后台-删除会议列表说明")
    @GetMapping("/deleteMeetings")
    public Result deleteMeetings(@RequestParam("id") Integer id) {
        return meetingService.deleteMeetings(id);
    }

    @ApiOperation(value="后台-获取会议列表接口",notes ="前台-获取会议列表接口说明")
    @PostMapping("/getAllMeetings")
    public Result getAllMeetings(@RequestBody PageRequest pageRequest) {
        return meetingService.getAllMeetings(pageRequest);
    }


    @ApiOperation(value="前台-获取唯一的UserSig接口",notes ="前台-获取唯一的UserSig接口说明")
    @GetMapping("/getUserSig")
    public Result getUserSig(@RequestParam("username")String username) {
        return meetingService.getUserSig(username);
    }

    @ApiOperation(value="获取用户列表接口",notes ="获取用户列表接口说明")
    @GetMapping("/getUserList")
    public Result getUserList(@RequestParam("id") Integer id) {
        return meetingService.getUserList(id);
    }
}
